import { api } from './request'

/**
 * 权限管理相关API接口
 */
export const permissionApi = {
  /**
   * 获取权限列表
   * @param params 查询参数
   */
  getPermissionList: (params: {
    page: number
    pageSize: number
    name?: string
    code?: string
    type?: number
  }) => {
    return api.get('/permission/list', params)
  },

  /**
   * 获取所有权限
   */
  getAllPermissions: () => {
    return api.get('/permission/all')
  },

  /**
   * 添加权限
   * @param data 权限数据
   */
  addPermission: (data: {
    name: string
    code: string
    type: number
    description?: string
  }) => {
    return api.post('/permission/add', data)
  },

  /**
   * 编辑权限
   * @param data 权限数据
   */
  updatePermission: (data: {
    id: number
    name: string
    code: string
    type: number
    description?: string
  }) => {
    return api.put('/permission/update', data)
  },

  /**
   * 删除权限
   * @param id 权限ID
   */
  deletePermission: (id: number) => {
    return api.delete(`/permission/delete/${id}`)
  }
}